import java.util.Random;
import java.util.Scanner;

public class demo{


    //求最大公约数（简化）
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=a%b;
        while(c!=0){
            a=b;
            b=c;
            c=a%b;
        }
        System.out.println("最大公约数为："+b);

    }

    //求是否是素数(提高效率)
    public static void main2(String[] args) {
        Scanner sc=new Scanner(System.in);
        int num=sc.nextInt();
        int i;
        for(i=2;i<=Math.sqrt(num);i++){
            if(num%i==0){
                System.out.println(num+"不是素数");
                break;
            }
        }
        if(i>Math.sqrt(num)){
            System.out.println(num+"是素数");
        }
    }

    //求X形图案
    public static void main1(String[] args) {
        Scanner sc=new Scanner(System.in);
        int sum=sc.nextInt();
        for (int i = 0; i < sum; i++) {
            for (int j = 0; j < sum; j++) {
                if(i==j||(i+j)==(sum-1)){
                    System.out.print("*");
                }
                else{
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }

    //猜数字游戏
    public static void main0314(String[] args) {
        Scanner sc=new Scanner(System.in);
        Random random=new Random();
        System.out.print("请输入你要猜的数字:");
        int guess=sc.nextInt();
        int toguess=random.nextInt(100);
        while(true){
            if(guess>toguess){
                System.out.println("猜大了");
            }
            else if (guess<toguess){
                System.out.println("猜小了");
            }
            else{
                System.out.println("猜对了");
                break;
            }
            System.out.print("请输入你要猜的数字:");
            guess=sc.nextInt();
        }

    }

    public static void main0312(String[] args) {
        int num=15,num1=0,num2=0;
        while(num!=0){
            num1=num1*10+1;
        }

    }

    public static void main0313(String[] args) {
        Scanner sc=new Scanner(System.in);
        int num= sc.nextInt();
        while(num!=0){
            System.out.println(num%10);
            num/=10;
        }
    }

    public static void main0311(String[] args) {
        Scanner sc=new Scanner(System.in);
        int num=sc.nextInt();
        int count=0;
        while(num!=0){
            num/=2;
            count++;
        }
        System.out.println(count);
    }
}
